<#assign module="marketing"/>

<@override name="header">
<link rel="stylesheet" href="${ctx}/assets/css/uploadify.css">
<link rel="stylesheet" href="${ctx}/assets/css/datetimepicker.css">
</@override>
<@override name="body">

	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-default">
				<div class="panel-heading">
					修改品牌信息
			    </div>
			    <div class="panel-body">
    				<form id="submit_form" action="${ctx}/brand/update" class="form-horizontal" method="post" enctype="multipart/form-data">
		               	<input type="hidden" name="id" value="${brand.id}">
		               	
		                <div class="form-group">
		                    <label class="col-sm-3 control-label">添加时间：</label>
		                    <div class="col-sm-3">
		                    	<input class="form-control"  style="background-color:#fff;" type="text"  value="${brand.created?string('yyyy-MM-dd HH:mm')}" readonly="readonly"/>
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-sm-3 control-label"><em>*</em>品牌名称：</label>
		                    <div class="col-sm-3">
		                    	<input class="form-control" id="name" name="name" type="text"  value="${brand.name?if_exists}" required/>
		                    </div>
		                </div>
		                
		                <div class="form-group">
		                    <label class="col-sm-3 control-label"><em>*</em>品牌顺序：</label>
		                    <div class="col-sm-3">
		                    	<input class="form-control" id="sequence" name="sequence" type="number"  value="${brand.sequence?if_exists}" required/>
		                    </div>
		                </div>
						
						<div class="form-group">
		                    <label class="col-sm-3 control-label"><em>*</em>品牌图片：</label>
		                  	<div class="col-sm-2">
								<div style="margin-top:10px">
									<img id="picture_img" style="width:200px;height:200px;" src="${ctx}/${brand.photo}"/>
								</div>
								<input style="display:none;" type="file" name="pic1" id="picture_file" accept=".bmp,.gif,.jpeg,.jpg,.png">
								<input id="picture_brand" type="hidden" name="photo" value="${brand.photo}" />
							</div>
							<div class="col-sm-1">
							<button type="button" class="pull-left button button-pill button-flat-primary button-tiny " id="picture_upload_brand"><i class="glyphicon glyphicon-open"></i>&nbsp;图片上传</button>
							</div>
		                </div>
		                		                
		                <div class="form-group" style="margin-left:10px;">
		                	<label class="col-sm-4 control-label"></label>
			                <input id="submit_button" type="submit" class="btn btn-primary" value="保存">
			                <input type="button" class="btn btn-default" onclick="window.location.href = '${ctx}/brand/list';" value="返回">
			            </div>
			            
					</form>
        		</div>
			</div>
		</div>
	</div>

</@override>
<@override name="footer">
<script src="${ctx}/assets/js/ajaxfileupload.js"></script>
<script src="${ctx}/assets/kindeditor/kindeditor-all-min.js"></script>
<script src="${ctx}/assets/kindeditor/lang/zh_CN.js"></script>
<script src="${ctx}/assets/js/bootstrap-datetimepicker.min.js"></script>
<script src="${ctx}/assets/js/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		
		$("#picture_upload_brand").click(function(){
			$("#picture_file").click();
		});
		$("#picture_img").click(function(){
			$("#picture_file").click();
		});
		
		$(document).on('change','#picture_file',function(){
			if($.trim($(this).val())){
			 	$.ajaxFileUpload({
	                url:'${ctx}/common/uploadTemp',
	                secureuri:false,
	                fileElementId:'picture_file',
	                dataType: 'json',
	                data:{'type':'brand'},
	                success: function (result, textStatus) {
	                
	                	$('#picture_img').attr('src','${ctx}/upload/brand/'+result.url);
	                	var url='upload/brand/'+result.url;
	                	$('#picture_brand').val(url);
	                }
	            });
			}
		});
		
		
		$("#submit_form").submit(function(){
			$("#submit_button").attr("disabled",true);
			
			if($("#name").val()==""){
		    	$.scojs_message('请填写品牌名称', $.scojs_message.TYPE_ERROR);
		    	$("#submit_button").attr("disabled",false);
		    	return false;
		    }
			
		    if($("#picture").val()==""){
		    	$.scojs_message('请上传品牌图片', $.scojs_message.TYPE_ERROR);
		    	$("#submit_button").attr("disabled",false);
		    	return false;
		    }
		    
			return true;
		});
	
	});
</script>
</@override>
<@extends name="../layout.ftl"/>